package com.heima.article.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.common.constant.GlobalConstant;
import com.heima.model.article.pojos.ApArticleConfig;
import com.heima.article.mapper.ApArticleConfigMapper;
import com.heima.article.service.ApArticleConfigService;
import com.heima.model.wemedia.pojos.WmNews;
import org.apache.commons.net.nntp.Article;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class ApArticleConfigServiceImpl extends ServiceImpl<ApArticleConfigMapper, ApArticleConfig> implements ApArticleConfigService {
    @Override
    public void updateEnableByMap(Map map) {
        try{
            Long articleId = (Long)map.get(GlobalConstant.ARTICLE_ID_TAG);
            Short enable=((Integer)map.get(GlobalConstant.ENABLE_TAG)).shortValue();
            boolean isDown=true;
            if (enable.equals(WmNews.Enable.ENABLE.getValue()))
            {
                isDown=false;
            }
            this.update(Wrappers.<ApArticleConfig>lambdaUpdate().eq(ApArticleConfig::getArticleId,articleId).set(ApArticleConfig::getIsDown,isDown));
        }catch (Exception e){
            log.error("map 异常->"+map);
        }

    }
}
